package com.edu.oracle.service.impl;

import com.edu.oracle.dao.StudentDao;
import com.edu.oracle.pojo.Student;
import com.edu.oracle.pojo.ViewStudent;
import com.edu.oracle.service.StudentService;

import java.util.List;

//alt + 回车键实现方法
public class StudentServiceImpl  implements StudentService {
    //注入StudentDao类,创建studentDao类
    StudentDao studentDao =new StudentDao();

    @Override
    public List<Student> getStuList() {
        ///测试，是否成功，看控制台

        System.out.println("StudentServiceImpl实现类");

        //调用dao类
        List<Student> studentList=studentDao.getStudentList();

        return studentList;
    }

    @Override
    public Student selectByOne(String sno) {///实现层，在分页查询，条件查询
        //调用dao层的studentDao
        Student student=studentDao.selectByOne(sno);
        return student;//return返回把null 改成student
    }

    @Override
    public List<ViewStudent> viewSelect() {
        //调用dao持久层的viewselect查询方法
        List<ViewStudent> students = studentDao.viewSelect();
        return students;
    }

    @Override
    public boolean updateStudent(Student student) {
        //调用dao持久层的updateStudent更新方法
        boolean bl =studentDao.updateStudent(student);



        //在这里拼接条件，查最大值，max函数（给参数）
        return bl;
    }

    @Override
    public boolean addByOne(Student student) {
        //调用dao持久层  data access object
        Boolean bl = studentDao.addByOne(student);
        return bl;
    }

    @Override
    public void deleteStudent(String sno) {//void类型为空，不需要返回，只有它不需要返回
        //调用dao持久层
        studentDao.deleteStudent(sno);//调用框架，有时候 service的方法和dao持久层方法是不一样的
    }

/*    @Override
    public boolean deleteStudent1(String sno) {//void类型为空，不需要返回，只有它不需要返回
        //调用dao持久层
        boolean bl =studentDao.deleteStudent(sno);

        return  studentDao.deleteStudent(sno);
    }*/
}
